home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / InvisibleButton.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-12-16  |  2.0 KB  |  86 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.awt.Canvas;
  4. import java.awt.Component;
  5. import java.awt.Event;
  6. import java.awt.Graphics;
  7. import java.awt.Image;
  8. import java.awt.Rectangle;
  9. import java.awt.image.ImageObserver;
  10. import symantec.beans.Beans;
  11.  
  12. public class InvisibleButton extends Canvas {
  13.    protected boolean pressed = false;
  14.    // $FF: renamed from: pc java.awt.Component
  15.    private Component field_0;
  16.    private Rectangle pbt;
  17.    private Rectangle pbc;
  18.    // $FF: renamed from: pi java.awt.Image
  19.    private Image field_1;
  20.  
  21.    protected void paintComponent(Component var1, Graphics var2) {
  22.       Rectangle var3 = var1.bounds();
  23.       Rectangle var4 = ((Component)this).bounds();
  24.       if (var3.intersects(var4)) {
  25.          boolean var5 = false;
  26.          if (this.field_0 == null || this.field_0 != var1) {
  27.             this.field_0 = var1;
  28.             var5 = true;
  29.          }
  30.  
  31.          if (this.pbt == null || !this.pbt.equals(var4)) {
  32.             this.pbt = var4;
  33.             var5 = true;
  34.          }
  35.  
  36.          if (this.pbc == null || !this.pbc.equals(var3)) {
  37.             this.pbc = var3;
  38.             var5 = true;
  39.          }
  40.  
  41.          if (var5 || this.field_1 == null) {
  42.             if (this.field_1 != null) {
  43.                this.field_1.flush();
  44.             }
  45.  
  46.             this.field_1 = ((Component)this).createImage(var3.width, var3.height);
  47.             if (Beans.isDesignTime()) {
  48.                System.gc();
  49.             }
  50.          }
  51.  
  52.          Graphics var6 = this.field_1.getGraphics();
  53.          var1.paint(var6);
  54.          var2.drawImage(this.field_1, var3.x - var4.x, var3.y - var4.y, (ImageObserver)null);
  55.          var6.dispose();
  56.       }
  57.  
  58.    }
  59.  
  60.    public void paint(Graphics var1) {
  61.       Component[] var2 = ((Component)this).getParent().getComponents();
  62.  
  63.       for(int var3 = 0; var3 < var2.length; ++var3) {
  64.          Component var4 = var2[var3];
  65.          if (!(var4 instanceof InvisibleButton)) {
  66.             this.paintComponent(var4, var1);
  67.          }
  68.       }
  69.  
  70.    }
  71.  
  72.    public boolean mouseDown(Event var1, int var2, int var3) {
  73.       this.pressed = true;
  74.       return true;
  75.    }
  76.  
  77.    public boolean mouseUp(Event var1, int var2, int var3) {
  78.       if (this.pressed) {
  79.          this.pressed = false;
  80.          ((Component)this).postEvent(new Event(this, 1001, (Object)null));
  81.       }
  82.  
  83.       return true;
  84.    }
  85. }
  86.